import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';
import 'package:zenge_web_flutter/custom/appBar_widget.dart';
import 'package:zenge_web_flutter/custom/custom_widget.dart';
import 'package:zenge_web_flutter/view/keep_alive.dart';

import 'state.dart';

Widget buildView(
    BridgeProductsState state, Dispatch dispatch, ViewService viewService) {
  double screenWidth = 1920;
  return Scaffold(
    body: Container(
      width: MediaQuery.of(viewService.context).size.width,
      alignment: Alignment.center,
      child: Container(
        width: screenWidth,
        alignment: Alignment.center,
        child: ListView(
          shrinkWrap: true,
          controller: state.scrollController,
          children: [
            Stack(
              children: [
                Positioned(
                  top: 65,
                  child: ImageNetWork(
                    width: screenWidth,
                    // height: 1932/1920*screenWidth,
                    imageUrl:
                        'http://nwzimg.wezhan.hk/contents/sitefiles3603/18018508/images/2087454.jpg',
                  ),
                ),
                AppBarWidget(boxHeight: 1932,),
              ],
            ),
            ImageWidget(
              width: screenWidth,
              height: 1500/1920*screenWidth,
              imageUrl:
                  'http://nwzimg.wezhan.hk/contents/sitefiles3603/18018508/images/2087455.jpg',
            ),
            ImageWidget(
              width: screenWidth,
              height: 1459/1920*screenWidth,
              imageUrl:
                  'http://nwzimg.wezhan.hk/contents/sitefiles3603/18018508/images/2087456.jpg',
            ),
            ImageWidget(
              width: screenWidth,
              height: 1607/1920*screenWidth,
              imageUrl:
                  'http://nwzimg.wezhan.hk/contents/sitefiles3603/18018508/images/2087457.jpg',
            ),
            KeepAliveWidget(viewService.buildComponent("bottom_info")),
          ],
        ),
      ),
    ),
      floatingActionButton: FloatingActionButton(
        backgroundColor: Colors.white,
        onPressed: () {
          // scrollController 通过 animateTo 方法滚动到某个具体高度
          // duration 表示动画的时长，curve 表示动画的运行方式，flutter 在 Curves 提供了许多方式
          state.scrollController.animateTo(0.0,
              duration: Duration(milliseconds: 500),
              curve: Curves.decelerate);
        },
        child: Icon(Icons.arrow_upward_sharp,color: Colors.grey,size: 40,),
      )
  );
}
